package org.example.spring02aop.proxy.statics;

import org.example.spring02aop.calculator.MathCalculator;
import org.example.spring02aop.impl.MathCalculatorImpl;
import org.springframework.stereotype.Component;

//@Component
public class CalculatorStaticProxy implements MathCalculator {

    private MathCalculator target;// 目标对象

    public CalculatorStaticProxy(MathCalculator mc) {
        this.target = mc;
    }

    @Override
    public int add(int i, int j) {
        System.out.println("【日志】add开始：参数："+ i + "，" + j);
        int result = target.add(i, j);
        System.out.println("【日志】add结束：结果：" + (i + j));
        return result;
    }

    @Override
    public int sub(int i, int j) {
        System.out.println("【日志】sub开始：参数："+ i + "，" + j);
        int result = target.sub(i, j);
        System.out.println("【日志】sub结束：结果：" + (i - j));
        return result;
    }

    @Override
    public int mul(int i, int j) {
        System.out.println("【日志】mul开始：参数："+ i + "，" + j);
        int result =target.mul(i, j);
        System.out.println("【日志】mul结束：结果：" + (i * j));
        return result;
    }

    @Override
    public int div(int i, int j) {
        System.out.println("【日志】div开始：参数："+ i + "，" + j);
        int result =target.div(i, j);
        System.out.println("【日志】div结束：结果：" + (i / j));
        return result;
    }
}
